package jpm.position;

import static jpm.common.AssertUtils.ensureNotNull;

public final class PositionKey  {

	// this class is immutable

	public PositionKey(String security, String accountNo) {
		ensureNotNull(security, "security is null");
		ensureNotNull(accountNo, "accountNo is null");

		this.security = security;
		this.accountNo = accountNo;
	}

	public String getAccountNo() {
		return accountNo;
	}

	public String getSecurity() {
		return security;
	}

	private final String accountNo;
	private final String security;

	// will be used a key in position cache map. implement hashCode and equals

	@Override
	public int hashCode() {
		return (accountNo + "_" + security).hashCode();
	}

	@Override
	public boolean equals(Object o) {
		if (!(o instanceof PositionKey))
			return false;

		PositionKey positionKeyProp = (PositionKey) o;

		return this.accountNo.equals(positionKeyProp.getAccountNo())
				&& this.security.equals(positionKeyProp.getSecurity());
	}
}
